package com.asj.house.controller;


import com.asj.house.entity.HouseIntermediary;
import com.asj.house.entity.HouseRoomIntermediary;
import com.asj.house.returns.RespEntity;
import com.asj.house.returns.RespTable;
import com.asj.house.service.HouseIntermediaryService;
import com.asj.house.vo.param.RoomParam;
import io.swagger.annotations.Api;
import java.util.List;

import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * <p>
 * 中介信息表 前端控制器
 * </p>
 *
 * @author asj
 * @since 2021-03-16
 */
@RestController
@RequestMapping("/house-intermediary")
@Api(value = "中介信息接口", tags = "中介信息接口")
public class HouseIntermediaryController {

    @Resource
    private HouseIntermediaryService houseIntermediaryService;

    @GetMapping("/list")
    @ApiOperation(value = "中介信息列表")
    public RespTable<List<HouseIntermediary>> listHouseIntermediary(RoomParam roomParam) {
        RespTable<List<HouseIntermediary>> respTable = houseIntermediaryService.listHouseRoomIntermediary(roomParam);
        return respTable;
    }

    @PostMapping("/insert")
    @ApiOperation(value = "新增中介信息")
    public RespEntity insertHouseIntermediary(@RequestBody HouseIntermediary houseIntermediary) {
        RespEntity respEntity = houseIntermediaryService.insertHouseIntermediary(houseIntermediary);
        return respEntity;
    }

    @PutMapping("/update")
    @ApiOperation(value = "编辑中介信息")
    public RespEntity updateHouseIntermediary(@RequestBody HouseIntermediary houseIntermediary) {
        RespEntity respEntity = houseIntermediaryService.updateHouseIntermediary(houseIntermediary);
        return respEntity;
    }

    @DeleteMapping("/delete")
    @ApiOperation(value = "删除中介信息")
    @ApiImplicitParam(paramType = "delete", dataType = "Integer", name = "id", value = "中介id", required = true)
    public RespEntity deleteHouseIntermediary(@RequestParam(value = "id", required = true) Integer id) {
        RespEntity respEntity = houseIntermediaryService.deleteHouseIntermediary(id);
        return respEntity;
    }

    @DeleteMapping("/deleteBatch")
    @ApiOperation(value = "批量删除中介信息")
    public RespEntity deleteBatchHouseIntermediary(@RequestParam("ids") Integer[] ids) {
        RespEntity respEntity = houseIntermediaryService.deleteBatchHouseIntermediary(ids);
        return respEntity;
    }

}
